package com.jy.api.controller.common;

import com.jy.api.service.WechatTemplateService;
import com.jy.api.signUpReq.admin.NoticeSignUpReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by lihu on 2017/12/18.
 */
@Slf4j
@RequestMapping(value = "/v1/system", produces = "application/json;charset=utf-8")
@RestController
public class NoticeController {


    @Autowired
    WechatTemplateService wechatTemplateService;

    @RequestMapping(value = "/notice", method = RequestMethod.POST)
    public ResponseEntity sendNotice(@RequestBody NoticeSignUpReq noticeSignUpReq) {
        try {
            wechatTemplateService.sendAmountNotice(noticeSignUpReq.getTitle(), noticeSignUpReq.getNotice());
            return new ResponseEntity(HttpStatus.OK);
        } catch (Exception ex) {
            log.error("sendNotice is error:{}", ex);
            return new ResponseEntity("系统运行错误", HttpStatus.INTERNAL_SERVER_ERROR);
        }

    }


}
